package mo.leetcode_top;

import java.util.*;

public class L187 {

    public List<String> findRepeatedDnaSequences(String s) {
        Set<String> all = new HashSet<>();
        Set<String> res = new LinkedHashSet<>();
        for (int i = 0; i <= s.length() - 10; i++) {
            String subString = s.substring(i, i+10);
            if (all.contains(subString)) {
                res.add(subString);
            } else {
                all.add(subString);
            }
        }
        return new ArrayList<>(res);
    }

    public static void main(String[] args) {
        L187 tes = new L187();
        System.out.println(tes.findRepeatedDnaSequences("AAAAAAAAAAA"));
    }
}
